package com.task.controller.custom;


import com.task.common.annotation.Log;
import com.task.common.entity.custom.Task;
import com.task.common.entity.custom.model.CreateTaskModel;
import com.task.common.entity.custom.model.QueryTaskModel;
import com.task.common.entity.custom.model.UpdateTaskModel;
import com.task.common.enums.BusinessType;
import com.task.common.util.body.JsonResult;
import com.task.common.util.body.ResultTool;
import com.task.common.util.model.ModelUtil;
import com.task.service.ITaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Huzz
 * @since 2022-05-21
 */
@Api(tags = "员工任务管理")
@RestController
@RequestMapping("/cust/task")
public class CustTaskController {

    @Autowired
    private ITaskService taskService;

    @ApiOperation("更新任务报告")
    @Log(title = "更新任务报告", businessType = BusinessType.INSERT, isSaveRequestParam = true)
    @PutMapping("/submitTaskModification/{taskId}")
    public JsonResult submitTaskModification(@PathVariable(name = "taskId") Integer taskId,
                                             @ApiParam(name = "schedule",value = "进度[0-100]")@RequestParam Integer schedule,
                                             @ApiParam(name = "status",value = "进度", allowableValues = "2,4")@RequestParam Integer status) {
        return taskService.submitTaskModification(taskId,schedule,status) ? ResultTool.success() : ResultTool.fail();
    }

    @ApiOperation("员工任务列表")
    @Log(title = "员工任务列表", businessType = BusinessType.INSERT, isSaveRequestParam = true)
    @GetMapping("/findCustTaskList")
    public JsonResult findCustTaskList(QueryTaskModel model) {
        return ResultTool.success(taskService.findCustTaskList(model));
    }

}
